home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17541 < prev    next >
Encoding:
Text File  |  1996-08-05  |  742 b   |  29 lines

  1. Path: grimsel.zurich.ibm.com!usenet
  2. From: Keith Whittingham <wgk@zurich.ibm.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: downcast with virtual base class - illegal but why
  5. Date: Tue, 16 Apr 1996 14:52:23 -0700
  6. Organization: IBM Zurich Research Laboratory
  7. Message-ID: <31741697.7881@zurich.ibm.com>
  8. NNTP-Posting-Host: pine.zurich.ibm.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.01 (Win16; I)
  13.  
  14. I am reminded of this problem from a recent post but lost the post.
  15.  
  16. class Base { };
  17. class Der : public virtual Base {};
  18.  
  19. Der d;
  20. Base *b = &d;
  21. Der *dp = (Der *)b; // error
  22.  
  23. I know the downcast from a virtual base class is illegal but why?
  24.  
  25.  
  26. -- 
  27. Keith Whittingham
  28. wgk@zurich.ibm.com
  29.